#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 100010;
pair<int, int> p[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i].second >> p[i].first;  //first->r second->l
    }
    sort(p, p + n);
    int res = 0, ed = -2e9;
    for (int i = 0; i < n; i++)
    {
        if (p[i].second > ed)
        {
            res++;
            ed = p[i].first;
        }
    }
    cout << res << endl;
    return 0;
}
